{extend name="pub/base" /}
{block name="title"}
<title>执行sql</title>
{/block}
{block name="body"}
<div class="Hui-admin-article">
    <nav class="breadcrumb" style="background-color:#fff;padding: 0 24px">
        首页
        <span class="c-gray en">/</span>
        执行sql命令
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
           href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <div class="Hui-article">
        <article class="clearfix pd-20">
            <form action="{:url('sql')}" method="post" class="form form-horizontal">
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3">SQL语句：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <textarea name="sql" cols="" rows="" class="textarea" dragonfly="true"
                                  onKeyUp="textarealength(this,100)">
                        </textarea>
                        <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
                    </div>
                </div>


                <div class="row clearfix">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    </div>
                </div>
            </form>
        </article>
    </div>
</div>
<script>
    $(function () {
        /* 表单验证，提交 */
        $("form").validate({
            rules: {
                sql: {
                    required: true
                }
            },
            onkeyup: false,
            focusCleanup: false,
            submitHandler: function (form) {
                $.ajax({
                    url: "{:url('sql')}",
                    type: 'post',
                    data: $('form').serialize(),
                    success(res) {
                        subResHandle(res)
                    }
                })
            }
        });
    });
</script>
{/block}